var t = getApp();

Page({
    data: {
        currentResultOne: 0,
        currentResultTwo: 0,
        loadingBoo: !0,
        moreBooOne: !0,
        moreBooTwo: !0,
        // 信息
        resultListOne: [
          {
            orderId:1,
            doctorId:1,
            patientSimpleVo:{
              userId:1,
              userIcon: '/assets/images/head.png',
              name:'小花',
              nmGender:'女',
              age:30
            },
            medType:1,
            teamMyUserId:1,
            msgTxt: '你是谁',
            sessionDateBegin:'2018-10-22 16:11',
            status:0,
            nonReadCount:0
          },
          {
            orderId: 1,
            doctorId: 1,
            patientSimpleVo: {
              userId: 1,
              userIcon: '/assets/images/head.png',
              name: '小花',
              nmGender: '女',
              age: 30
            },
            medType: 1,
            teamMyUserId: 1,
            msgTxt: '你是谁',
            sessionDateBegin: '2018-10-22 16:11',
            status: 0,
            nonReadCount: 0
          },
          {
            orderId: 1,
            doctorId: 1,
            patientSimpleVo: {
              userId: 1,
              userIcon: '/assets/images/head.png',
              name: '小花',
              nmGender: '女',
              age: 30
            },
            medType: 1,
            teamMyUserId: 1,
            msgTxt: '你是谁',
            sessionDateBegin: '2018-10-22 16:11',
            status: 1,
            nonReadCount: 0
          },
          {
            orderId: 1,
            doctorId: 1,
            patientSimpleVo: {
              userId: 1,
              userIcon: '/assets/images/head.png',
              name: '小花',
              nmGender: '女',
              age: 30
            },
            medType: 1,
            teamMyUserId: 1,
            msgTxt: '你是谁',
            sessionDateBegin: '2018-10-22 16:11',
            status: 0,
            nonReadCount: 2
          }
        ],
        resultListTwo: [
          {
            orderId: 1,
            doctorId: 1,
            patientSimpleVo: {
              userId: 1,
              userIcon: '/assets/images/head.png',
              name: '小花',
              nmGender: '女',
              age: 30
            },
            medType: 1,
            teamMyUserId: 1,
            msgTxt: '你是谁',
            sessionDateBegin: '2018-10-22 16:11',
            status: 0,
            nonReadCount: 0
          },
          {
            orderId: 1,
            doctorId: 1,
            patientSimpleVo: {
              userId: 1,
              userIcon: '/assets/images/head.png',
              name: '小花',
              nmGender: '女',
              age: 30
            },
            medType: 1,
            teamMyUserId: 1,
            msgTxt: '你是谁',
            sessionDateBegin: '2018-10-22 16:11',
            status: 0,
            nonReadCount: 0
          },
          {
            orderId: 1,
            doctorId: 1,
            patientSimpleVo: {
              userId: 1,
              userIcon: '/assets/images/head.png',
              name: '小花',
              nmGender: '女',
              age: 30
            },
            medType: 1,
            teamMyUserId: 1,
            msgTxt: '你是谁',
            sessionDateBegin: '2018-10-22 16:11',
            status: 1,
            nonReadCount: 0
          },
          {
            orderId: 1,
            doctorId: 1,
            patientSimpleVo: {
              userId: 1,
              userIcon: '/assets/images/head.png',
              name: '小花',
              nmGender: '女',
              age: 30
            },
            medType: 1,
            teamMyUserId: 1,
            msgTxt: '你是谁',
            sessionDateBegin: '2018-10-22 16:11',
            status: 1,
            nonReadCount: 2
          }
        ],
        explanBooOne: !1,
        explanBooTwo: !1
    },
    clickNum: function(t) {
        console.log(t.target.dataset.num);
        var a = this;
        this.setData({
            _num: t.target.dataset.num,
            explanBooOne: !1,
            explanBooTwo: !1,
            currentResultOne: 0,
            currentResultTwo: 0
        }), this.getPatientList(a);
    },
    reply: function(t) {
        wx.navigateTo({
          url: "/hyb_yl/backstageFollowUp/pages/explanationReply/explanationReply"
        });
    },
    onLoad: function(t) {
        var a = this;
        this.setData({
            _num: 0,
            teamName: t.teamName,
            teamId: t.teamId
        }), wx.setNavigationBarTitle({
            title: a.data.teamName
        });
    },
    onShow: function() {
        var t = this;
        t.setData({
            currentResultOne: 0,
            currentResultTwo: 0,
            explanBooTwo: !1,
            explanBooOne: !1
        }), t.setData({
            token: wx.getStorageSync("log")
        }), console.log(t.data._num), t.getPatientList(t);
    },
    getMore: function() {
        var t = this;
        console.log("下一页"), t.getPatient(t);
    },
    getPatient: function(a) {
        if (console.log(a.data._num), 0 == a.data._num) var e = a.data.resultListOne, o = a.data.currentResultOne, n = a.data.moreBooOne; else if (1 == a.data._num) var e = a.data.resultListTwo, o = a.data.currentResultTwo, n = a.data.moreBooTwo;
        n && a.data.loadingBoo && (0 != o && this.setData({
            loadingBoo: !1
        }), console.log(111111), 
        // 提示框
        // wx.showLoading({
        //     title: "加载中...",
        //     mask: !0
        // }), 
        wx.request({
            url: t.globalData.doctor + "doctor/advicemanage/teamMedOrder/list",
            data: {
                token: a.data.token,
                currentResult: o,
                status: a.data._num,
                teamId: a.data.teamId
            },
            success: function(n) {
                if (console.log(n), 200 == n.data.code) {
                    if (a.setData({
                        loadingBoo: !0
                    }), wx.hideLoading(), n.data.data.result.length <= 0 && 0 != o) return a.setData({
                        loadingBoo: !0
                    }), 0 == a.data._num && a.setData({
                        moreBooOne: !1
                    }), 1 == a.data._num && a.setData({
                        moreBooTwo: !1
                    }), console.log(a.data.moreBooTwo), void console.log(a.data.moreBooOne);
                    n.data.data.result.forEach(function(a) {
                        a.sessionDateBegin = t.toDate(a.sessionDateBegin), e.push(a);
                    }), 0 == a.data._num ? (a.setData({
                        resultListOne: e,
                        currentResultOne: n.data.data.page.nextResult,
                        loadingBoo: !0
                    }), 0 == e.length && a.setData({
                        explanBooOne: !0
                    })) : 1 == a.data._num && (a.setData({
                        resultListTwo: e,
                        currentResultTwo: n.data.data.page.nextResult,
                        loadingBoo: !0
                    }), 0 == e.length && a.setData({
                        explanBooTwo: !0
                    }));
                }
            },
            fail: function() {
                wx.showToast({
                    title: "系统繁忙，请稍后重试",
                    icon: "none",
                    duration: 2e3
                });
            }
        }));
    },
    getPatientList: function(a) {
        var e = [];
        if (0 == a.data._num) o = a.data.currentResultOne; else if (1 == a.data._num) var o = a.data.currentResultTwo;
        console.log(111111), 
        // 提示框
        // wx.showLoading({
        //     title: "加载中...",
        //     mask: !0
        // }), 
        wx.request({
            url: t.globalData.doctor + "doctor/advicemanage/teamMedOrder/list",
            data: {
                token: a.data.token,
                currentResult: o,
                status: a.data._num,
                teamId: a.data.teamId
            },
            success: function(o) {
                console.log(o), 200 == o.data.code && (wx.hideLoading(), o.data.data.result.length > 0 && o.data.data.result.forEach(function(a) {
                    a.sessionDateBegin = t.toDate(a.sessionDateBegin), e.push(a);
                }), 0 == a.data._num ? (a.setData({
                    resultListOne: e,
                    currentResultOne: o.data.data.page.nextResult
                }), 0 == e.length && a.setData({
                    explanBooOne: !0
                })) : 1 == a.data._num && (a.setData({
                    resultListTwo: e,
                    currentResultTwo: o.data.data.page.nextResult
                }), 0 == e.length && a.setData({
                    explanBooTwo: !0
                })));
            },
            fail: function() {
                wx.showToast({
                    title: "系统繁忙，请稍后重试",
                    icon: "none",
                    duration: 2e3
                });
            }
        });
    }
});